package com.museum.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.museum.entity.DO.UserRole;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Ruiwen
 * @since 2020-12-19
 */
@Repository

public interface UserRoleMapper extends BaseMapper<UserRole> {
    @Select("SELECT user_id from user_role where role_id=#{roleId}")
    List<Integer> getUserIdsByRoleId(Integer roleId);

    @Select("Select id from user_role where user_id = #{userId}")
    String getIdByUserId(String userId);

    @Update("Update user_role set role_id = #{roleId}  where user_id =#{userId}")
    int updateByUserId(Integer userId,Integer roleId);


    @Select("SELECT role_id from user_role where user_id = #{userId}")
    Integer selectRoleIdByUserId(Integer userId);

    @Select("select role_id from user_role where user_id = #{userId}")
    Integer getRoleIdByUserId(Integer userId);

}
